#![no_std]
use soroban_sdk::{auth::{Context, CustomAccountInterface}, crypto::Crypto,
                  contract, contracterror, contractimpl, contracttype,
                  symbol_short, Address, BytesN, Env, Map, String,
                  Symbol, TryIntoVal,vec,Error,Val,
                  Vec, Bytes, U256, IntoVal, assert_with_error};
use soroban_sdk::crypto::Hash;
use soroban_sdk::xdr::{FromXdr, PublicKey, ToXdr};

use soroban_sdk::xdr::TypeVariant::Uint256;
use crate::admin::{has_administrator, read_administrator, write_administrator};
use crate::chain_id::{has_chain_id,read_chain_id,write_chain_id};
use crate::nonce::{write_nonce,has_nonce,read_nonce};
use crate::verifier::{read_verifier, write_verifier};
use crate::MessageExecuted::{has_task_key,write_task_key};
use crate::IEEA::{EncodedInfo};
use crate::ICrosschainVerifier::VerifierClient;
use crate::cross_chain_verifier::{ decode_and_verify, Secep256k1Signature};
use crate::threshold::{has_threshold, write_threshold,read_threshold};
use crate::Secp256k1Pubkey::{has_pubkey_count,has_pubkey_no, add_pubkey};



#[contract]
pub struct MessageContract;

#[contracterror]
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
#[repr(u32)]
pub enum AccError {
    NotEnoughSigners = 1,
    NegativeAmount = 2,
    BadSignatureOrder = 3,
    UnknownSigner = 4,
    InvalidContext = 5,
}
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
struct ReceiveMsgData {
    target_contract :Address,
    function_call_data :Bytes,
}

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct EncodeInfo {
    pub task_id: Bytes,
    pub network_id: U256,
    pub contract_addr: Address,
    pub wmb_receive: Symbol,
    pub message_type: String,
    pub nft_contract: Address,
    pub nft_id: i128,
    pub price_token: Bytes,
    pub price:i128,
    pub recipent: Bytes,
    pub buyer:Address,
    pub evm_source_chain_id: U256,
    pub evm_source_contract: Bytes

}



#[contractimpl]
impl MessageContract {
    pub fn init(env:Env, chain_id: U256, owner:Vec<BytesN<65>>, threshold:u128){

    }
    pub fn inbound_bytes(env:Env,
        network_id: U256,  //stellar chainid
        encoded_info: Bytes,
        encoded_proof: Bytes,){

        //let info = Bytes::from_xdr(&env, &encoded_info).unwrap();

        let encodeInfo = EncodeInfo::from_xdr(&env, &encoded_info).unwrap();

         env.events().publish(("inbound_bytes", "encodeInfo"), encodeInfo)

    }


}


